<?php

namespace app\api\model;

use think\db\Query;
use think\Model;
use think\model\Collection;
use think\model\concern\SoftDelete;
use think\Paginator;
use function config;

/**
 * @method Model create() static 往数据库插入一条数据
 * @method number update() static 返回影响的记录数
 * @method Query where() static 查询限定
 * @method Collection select() static 添加查询条件
 * @method Model find() static 查询结果
 * @method Query order static 查询限定
 * @method Query group static 查询限定
 * @method Query with static 查询限定
 * @method Query limit static 查询限定
 * @method Query cache static 缓存
 * @method Query join static 连接
 * @method Query field static 字段
 * @method Paginator paginate static 分页
 */

class BaseModel extends Model
{

    use SoftDelete;
    protected $hidden = [ 'delete_time' ];

    protected function prefixImgUrl($value, $data)
    {
        $final_url = $value;
        if ($data['from'] == 1)
        {
            $final_url = sprintf('%s/images/%s', config('setting.img_prefix'), $value);
            $final_url = str_replace('//', '/', $final_url);
        }
        return $final_url;
    }

}
